<?php

namespace Home\Controller;

class PositionController extends HomeController {
	
    protected $config = array('app_type' => 'master');

	/**
	  * 删除
	*/
	public function del() {
	    
		$id = $_POST['id'];
		$this -> _destory($id);
	}
	
	/** 插入新新数据  **/
	protected function _insert($name = CONTROLLER_NAME) {
	
		$model = D($name);
		$role = M('role');
	
		$insertRole = array(
			'name' => trim($_POST['name']),
			'is_del' => (int)$_POST['is_del'],
			'create_time' => time(),
			'update_time' => time(),
		);
		if (false === $model -> create()) {
			$this -> error($model -> getError());
		}
	
		$model->startTrans();
		$list = $model -> add();
		$status = $role->add($insertRole);
		if ($list &&  $status ) {
			$model->commit();
			$this -> assign('jumpUrl', get_return_url());
			$this -> success('新增成功!');
		} else {
			$model->rollback();
			$this -> error('新增失败!');
		}
	}
}
?>